package com.wwwarehouse.common.activity.x5webview;

import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;

import com.wwwarehouse.common.R;
import com.wwwarehouse.common.custom_widget.X5WebView;

public class X5WebViewActivity extends AppCompatActivity {
    private X5WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //视频为了避免闪屏和透明问题
        getWindow().setFormat(PixelFormat.TRANSLUCENT);

        setContentView(R.layout.activity_x5_web_view);
        mWebView = (X5WebView) findViewById(R.id.x5webview);

        Intent intent = getIntent();
        if (null != intent) {
            String url = intent.getStringExtra("url");
            if (!TextUtils.isEmpty(url)) {
                mWebView.loadUrl(url);
            }
        }
    }


    //处理webview进入多层，按返回键回到上一次，如果到顶层就结束Activity
    @Override
    public void onBackPressed() {
        if (mWebView.getWebView().canGoBack()) {
            mWebView.getWebView().goBack();
            return;
        }
        super.onBackPressed();
    }
}
